]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
keyboard: Shift key shouldn't latch the state unless long pressed
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 15 Feb 2018 11:20:51 +0000 (12:20 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 15 Feb 2018 18:36:36 +0000 (19:36 +0100)
Instead of latching all states, make shift unlatched by default, and only
latched when making a long press on the key. When not latched, the keyboard
will switch to the first level (alphabetic lowercase) after the first key
press.

Also, move the actual level switch to Key::pressed, so it feels more
reactive on long press.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/46

js/ui/keyboard.js

index ea66b837538212c2fb6c17fff197ef3213fabdb5..37e86fdb74db707a966ad40ef393c7af962f8764 100644 (file)
@@ -499,6 +499,7 @@ var Keyboard = new Lang.Class({
 
         this._enableKeyboard = false; // a11y settings value
         this._enabled = false; // enabled state (by setting or device type)
+        this._latched = false; // current level is latched
 
         this._a11yApplicationsSettings = new Gio.Settings({ schema_id: A11Y_APPLICATIONS_SCHEMA });
         this._a11yApplicationsSettings.connect('changed', Lang.bind(this, this._syncEnabled));
@@ -787,6 +788,9 @@ var Keyboard = new Lang.Class({
                         this._keyboardController.keyvalRelease(keyval);
                     button._keyvalPress = false;
                 }
+
+                if (!this._latched)
+                    this._setActiveLayer(0);
             }));
 
             layout.appendKey(button.actor, button.keyButton.keyWidth);
@@ -821,13 +825,16 @@ var Keyboard = new Lang.Class({
             let actor = extraButton.keyButton;
 
             extraButton.connect('pressed', Lang.bind(this, function() {
-                if (keyval != null)
+                if (switchToLevel != null) {
+                    this._setActiveLayer(switchToLevel);
+                    // Shift only gets latched on long press
+                    this._latched = (switchToLevel != 1);
+                } else if (keyval != null) {
                     this._keyboardController.keyvalPress(keyval);
+                }
             }));
             extraButton.connect('released', Lang.bind(this, function() {
-                if (switchToLevel != null)
-                    this._setActiveLayer(switchToLevel);
-                else if (keyval != null)
+                if (keyval != null)
                     this._keyboardController.keyvalRelease(keyval);
                 else if (action == 'hide')
                     this.hide();
@@ -835,6 +842,12 @@ var Keyboard = new Lang.Class({
                     this._popupLanguageMenu(actor);
             }));
 
+            if (switchToLevel == 1) {
+                extraButton.connect('long-press', Lang.bind(this, function() {
+                    this._latched = true;
+                }));
+            }
+
             /* Fixup default keys based on the number of levels/keys */
             if (key.label == '⇧' && numLevels == 3) {
                 if (key.right) {